#TidyTuesday

Daily distribution by shift

Click and drag to pan, hold Ctrl to change camera angle and orientation. This plot shows the distribution of squirrels in the am (gold) and pm (black) surveys on each day. The slider at the bottom can be used to change observational day.

Daily distribution by Primary Fur Color

Click and drag to pan, hold Ctrl to change camera angle and orientation. This plot shows the distribution of squirrels by primary fur color on each day. The slider at the bottom can be used to change observational day.

Daily distribution by Location

Click and drag to pan, hold Ctrl to change camera angle and orientation. This plot shows the distribution of squirrels by location on each day. The slider at the bottom can be used to change observational day.

Nearest neighbor data prep

neighboors=NA
for( i in unique(nyc_squirrels$date)){

date <- nyc_squirrels %>% filter(date==i)
  sp.mydata <- date 
  coordinates(sp.mydata) <- ~long+lat
  d <- distm(sp.mydata)
  min.d <- apply(d, 1, function(x) order(x, decreasing=F)[2])
  newdata <- cbind(date, date[min.d,], apply(d, 1, function(x) sort(x, decreasing=F)[2]))
 
  colnames(newdata) <- c(colnames(date), colnames(date), 'distance')
  
  neighboors <- rbind(neighboors,newdata[,c(3,6,8,9,39,44,45,73)])
}

for_neighbor_plot <- as.data.frame(cbind("pair" = c("Same Age", "Both Adults", "Both Juveniles", "Same Fur", "Both Black Fur", "Both Gray Fur", "Both Cinnamon Fur"),
                            "freq" = c(length(which(neighboors$age==neighboors$age.1))/nrow(neighboors),
                            length(which(neighboors$age==neighboors$age.1 & neighboors$age=="Adult"))/length(which(neighboors$age=="Adult")),
                            length(which(neighboors$age==neighboors$age.1 & neighboors$age=="Juvenile"))/length(which(neighboors$age=="Juvenile")),
                            length(which(neighboors$primary_fur_color==neighboors$primary_fur_color.1))/nrow(neighboors),
                            length(which(neighboors$primary_fur_color==neighboors$primary_fur_color.1 & neighboors$primary_fur_color.1=="Black"))/length(which(neighboors$primary_fur_color=="Black")),
                            length(which(neighboors$primary_fur_color==neighboors$primary_fur_color.1 & neighboors$primary_fur_color.1=="Gray"))/length(which(neighboors$primary_fur_color=="Gray")),
                            length(which(neighboors$primary_fur_color==neighboors$primary_fur_color.1 & neighboors$primary_fur_color.1=="Cinnamon"))/length(which(neighboors$primary_fur_color=="Cinnamon"))),
                            
                            "avg.dist"= c(NA, mean(neighboors$distance[which(neighboors$age=="Adult")]),
                                          mean(neighboors$distance[which(neighboors$age=="Juvenile")]),
                                          NA,
                                          mean(neighboors$distance[which(neighboors$primary_fur_color=="Black")]),
                                          mean(neighboors$distance[which(neighboors$primary_fur_color=="Gray")]),
                                          mean(neighboors$distance[which(neighboors$primary_fur_color=="Cinnamon")]))
                                              
                            ))

for_neighbor_plot <- for_neighbor_plot %>% mutate(freq=as.numeric(as.character(freq)))
for_neighbor_plot$pair <-  factor(for_neighbor_plot$pair, levels = c("Same Age", "Both Adults", "Both Juveniles", "Same Fur", "Both Black Fur", "Both Gray Fur", "Both Cinnamon Fur"))

Frequency of nearest neighbor sharing characteristics

This plot represents the frequency a given squirrels nearest neighbor shared the characteristics listed on the xaxis. Numbers indicate the average nearest neighbor distance in meters for a given category.

Daily proportion of counts per shift. Gold taken during AM, black during PM

Daily breakdown of Primary Fur Color

Evan W Barba

2019-10-29